﻿@namespace SE.PO.CInterface.Web.Pages.DB.SU
@page "/db/sus"
@using SE.PO.CInterface.Web.Clients
@using AutoMapper
@using SE.PO.CInterface.DBProtocols.SUs
@inject SUClient Client
@inject IMapper Mapper;
<PageContainer Title="监控单元">
    <Breadcrumb>
        <Breadcrumb>
            <BreadcrumbItem>首页</BreadcrumbItem>
            <BreadcrumbItem>数据库协议</BreadcrumbItem>
            <BreadcrumbItem>监控单元</BreadcrumbItem>
        </Breadcrumb>
    </Breadcrumb>
    <Content>
        <span>下级SC把监控对象配置根据“数据库接口定义”的数据结构存储到中间数据库表中，增加、修改和删除任何配置，下级SC必须保证能够及时的维护该中间数据库表中的数据。涉及到的中间数据库表有M_Area、M_Site、M_SU、M_Device、M_SIGNAL，M_SU，NodeModify，NodeUpdate。中间数据库表中的数据除了NodeUpdate外均由下级SC维护，下级SC保证上述表中的数据和下级SC的配置一致；NodeUpdate表由上级SC负责添加数据，下级SC定时获取数据并维护（删除）。</span>
    </Content>
    <ChildContent>
        <Card>
            <Button OnClick="@(() => { _addVisible = true; })" Type="primary" Style="margin-bottom:16px">
                新增监控单元
            </Button>
            <Button OnClick="@DeleteSelectedRows" Type="danger" Style="margin-bottom:16px">
                删除选定
            </Button>
            <Table @ref="_table"
                   TItem="SUDto"
                   DataSource="@_source"
                   Total="_total"
                   @bind-PageIndex="_pageIndex"
                   @bind-PageSize="_pageSize"
                   @bind-SelectedRows="_selectedRows"
                   OnChange="OnChange"
                   Size="TableSize.Small">
                <Selection Key="@(context.Id)"/>
                <PropertyColumn Title="下级SCID" Property="c => c.ScId" />
                <PropertyColumn Title="监控单元编码" Property="c => c.Id" />
                <PropertyColumn Title="监控单元资管编码" Property="c => c.SUAssetId"/>
                <PropertyColumn Title="机房" Property="c => c.RoomName" />
                <PropertyColumn Title="站点" Property="c => c.SiteName" />
                <PropertyColumn Title="生产厂家描述" Property="c => c.Productor" />
                <PropertyColumn Title="协议版本描述" Property="c => c.Version" />
                <PropertyColumn Title="投入运行时间" Property="c => c.BeginRunTime" />
                <PropertyColumn Title="设备型号" Property="c => c.DeviceModel" />
                <ActionColumn Width="160" Title="操作" Fixed="right">
                    <Space>
                        <SpaceItem>
                            <Button Danger OnClick="@(() => { _delVisible = true; Delete(context.Id);})">删 除</Button>
                        </SpaceItem>
                        <SpaceItem>
                            <Button OnClick="@(() => { _editVisible = true; Edit(context.Id);})">修 改</Button>
                        </SpaceItem>
                    </Space>
                </ActionColumn>
            </Table>
        </Card>
    </ChildContent>
</PageContainer>

<Modal Title="新增监控单元表"
       Centered="true"
       Visible="@_addVisible"
       OnOk="@AddHandleOk"
       OnCancel="@AddHandleCancel">
    <AddSUFrom @ref="_addFrom"
                 OnSuccess="async () => { _addVisible = false; await GetSourceAsync(_pageIndex, _pageSize);}"
                 OnFailure="() => { _addVisible = true; }"
                 OnCancel="() => { _addVisible = true; }" >
    </AddSUFrom>
</Modal>

<Modal Title="编辑监控单元表"
       Centered="true"
       Visible="@_editVisible"
       OnOk="@EditHandleOk"
       OnCancel="@EditHandleCancel">
    <EditSUFrom @ref="_editFrom"
                  Model="@_editModel"
                  OnSuccess="async () => { _editVisible = false; await GetSourceAsync(_pageIndex, _pageSize);}"
                  OnFailure="() => { _editVisible = true; }"
                  OnCancel="() => { _editVisible = true; }">
    </EditSUFrom>
</Modal>

<Modal Title="删除监控单元表"
       Centered="true"
       Visible="@_delVisible"
       OnOk="@DeleteHandleOk"
       OnCancel="@DeleteHandleCancel">
    <DelSUFrom @ref="_delFrom"
                 Model="DelModel"
                 Models="@DelModels"
                 OnSuccess="async () => { _delVisible = false; await GetSourceAsync(_pageIndex, _pageSize);}"
                 OnFailure="() => { _delVisible = true; }"
                 OnCancel="() => { _delVisible = true; }">
    </DelSUFrom>
</Modal>